<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:p="http://primefaces.org/ui">

<h:head>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />

	<link rel="stylesheet" href="../../css/bootstrap.min.css" />
	<title><h:outputText value="NP Pillar" /></title>
</h:head>
<h:body>

	<ui:insert name="header">
		<ui:include src="../template/header.xhtml" />
	</ui:insert>
	<ui:insert name="dialog">
		<ui:include src="../template/dialog.xhtml" />
	</ui:insert>
	<h:form id="mainForm">
		<p:panel header="Search Goals">
			<p:panelGrid columns="3" id="searchOptions" style="width:100%;margin:0 auto;">
				<p:outputPanel>
					<p:outputLabel style="display:block" value="Goal Type" />
					<p:selectOneMenu value="#{goalControler.condition.typeSeq}">
						<f:selectItem itemLabel="All" itemValue="0" />
						<f:selectItems value="#{goalTypeControler.baseList}" var="type"
							itemLabel="#{type.name}" itemValue="#{type.seq}" />
					</p:selectOneMenu>
				</p:outputPanel>
				<p:outputPanel>
					<p:outputLabel style="display:block" value="Owner" />
					<p:autoComplete value="#{goalControler.condition.employeeName}"
						placeholder="Type for hint..."
						completeMethod="#{workInfoControler.completeEmployeeName}"
						validator="#{workInfoControler.nameValidate}" />
				</p:outputPanel>
				<p:outputPanel>
					<p:outputLabel style="display:block" value="Goal" />
					<p:inputText value="#{goalControler.condition.name}" />
				</p:outputPanel>
				<p:outputPanel>
					<p:outputLabel style="display:block" value="Due Date" />
					<p:outputLabel style="display:block" value="From" />
					<p:calendar label="From" value="#{goalControler.condition.from}"
						showOn="both" pattern="yyyy-MM-dd" />
				</p:outputPanel>
				<p:outputPanel>
					<p:outputLabel style="display:block" value="&nbsp;" />
					<p:outputLabel style="display:block" value="To" />
					<p:calendar label="To" value="#{goalControler.condition.to}"
						showOn="both" pattern="yyyy-MM-dd" />
				</p:outputPanel>
				<p:outputPanel>
					<p:outputLabel style="display:block" value="Goal Status" />
					<p:selectManyCheckbox
						value="#{goalControler.condition.statusSeqs}">
						<f:selectItems value="#{goalStatusControler.baseList}" var="status"
							itemLabel="#{status.name}" itemValue="#{status.seq}" />
					</p:selectManyCheckbox>
				</p:outputPanel>
			</p:panelGrid>
			<p:commandButton value="Search" update="goalTable"
				actionListener="#{goalControler.search}" />
			<p:commandButton value="Reset" update="searchOptions"
				actionListener="#{goalControler.condition.clear}" />
		</p:panel>
		<p:panel header="Goal List">
			<p:commandButton value="Add"
				actionListener="#{goalControler.startAdd}"
				action="#{mainMenuControler.transfer}">
				<f:setPropertyActionListener target="#{mainMenuControler.nextMenu}"
					value="/faces/employee/editGoal.jsf" />
			</p:commandButton>
			<p:commandButton value="Delete"
				actionListener="#{goalControler.startDelete}"
				onclick="PF('deleteConfirm_w').show();" update="deleteConfirm" />

			<p:dataTable id="goalTable" value="#{goalControler.listModel}"
				var="goal" selection="#{goalControler.selecteds}" rows="10"
				first="#{goalControler.first}">
				<p:column style="width:2%" selectionMode="multiple">
				</p:column>
				<p:column style="width:10%" sortBy="#{goal.name}"
					headerText="Goal Name">
					<p:commandLink value="#{goal.name}"
						actionListener="#{goalControler.startEdit}"
						action="#{mainMenuControler.transfer}" ajax="false">
						<f:attribute name="goal" value="#{goal}" />
						<f:setPropertyActionListener
							target="#{mainMenuControler.nextMenu}"
							value="/faces/employee/editGoal.jsf" />
					</p:commandLink>
				</p:column>

				<p:column style="width:10%" headerText="Completion">
					<p:progressBar value="#{goal.completion}" labelTemplate="{value}%"
						displayOnly="true" />
				</p:column>
				<p:column style="width:10%" sortBy="#{goal.employee.name}"
					headerText="Owner">
					<h:outputText value="#{goal.employee.name}" />
				</p:column>
				<p:column style="width:10%" sortBy="#{goal.formatDue}"
					headerText="Due Date">
					<h:outputText value="#{goal.formatDue}" />
				</p:column>
				<p:column style="width:10%" sortBy="#{goal.status.name}"
					headerText="Status">
					<h:outputText value="#{goal.status.name}" />
				</p:column>
				<p:column style="width:10%" sortBy="#{goal.type.name}"
					headerText="Type">
					<h:outputText value="#{goal.type.name}" />
				</p:column>
			</p:dataTable>
		</p:panel>
		<p:confirmDialog id="deleteConfirm" widgetVar="deleteConfirm_w"
			message="Are you sure to delete these Goals?"
			visible="#{goalControler.deleteMode}"
			header="NP Pillar - Confirm Required" severity="alert">
			<p:focus context="deleteConfirm" for="cancelBtn" />
			<p:commandButton id="confirmBtn" value="OK" update="mainForm"
				onclick="PF('deleteConfirm_w').hide();"
				actionListener="#{goalControler.delete}" />
			<p:commandButton id="cancelBtn" value="Cancel"
				actionListener="#{goalControler.endDelete}"
				onclick="PF('deleteConfirm_w').hide();" />
		</p:confirmDialog>
	</h:form>
</h:body>
</html>
